<!DOCTYPE html>
<html>

<head>
	<title>companyReport.html</title>

	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="this is my page">
	<meta http-equiv="content-type" content="text/html; charset=UTF-8">
	<link rel="stylesheet" href="../../../plugins/bootstrap/css/bootstrap.min.css" type="text/css">
	</link>
	<link rel="shortcut icon" href="../../../plugins/FlatUI/dist/img/favicon.ico">
	<link rel="stylesheet" href="../../../css/style.css">
	<link rel="stylesheet" href="../../../plugins/datetimepicker/bootstrap-datetimepicker.css" type="text/css">
	</link>
	<script type="text/javascript" src="../../../js/jquery.js"></script>
	<script type="text/javascript" src="../../../plugins/FlatUI/dist/js/flat-ui.js"></script>
	<script type="text/javascript" src="../../../plugins/bootstrap/js/messager.js"></script>
	<script type="text/javascript" src="../../../plugins/datetimepicker/bootstrap-datetimepicker.js"></script>
	<script type="text/javascript" src="../../../plugins/datetimepicker/bootstrap-datetimepicker.zh-CN.js"></script>
	<script type="text/javascript" src="../../../js/base.js"></script>
	<script src="../../../js/template.js"></script>
	<script src="../../../js/bootstrap-paginator.js"></script>
	<script src="../../../js/bootstrap-mypaginator.js"></script>

	<script type="text/javascript">

		//分页查询
		function ajaxLoadData(data) {
			$.ajax({
				url: commonurl + "/selectCompanyReport.company",
				type: "POST",
				data: data,
				dataType: "json",
				success: function (data) {
					if (data.success) {
						obj = data.obj;
						console.log(obj);
						var datas = {
							sources: obj.list,
							commonurlimg: commonurlimg
						};
						$("#companyContent").html(template("companyTemplate", datas));
						myPaginatorFun("myPages", obj.pageNo, obj.pages);
					} else {
						alert(data.msg);
					}
				}

			})
		}

		$(function () {
			console.log("111");

			console.log($("#datetimepicker").data("datetimepicker").getDate().getFullYear() + "###");
			var year = $("#datetimepicker").data("datetimepicker").getDate().getFullYear();
			//刚进页面加载数据
			ajaxLoadData({

				pageNo: 1,
				year: year
			});
			myoptions.onPageClicked = function (event, originalEvent, type, page) {
				var year = $("#datetimepicker").data("datetimepicker").getDate().getFullYear();
				ajaxLoadData({
					pageNo: page,
					year: year
				});
			};
		})

		function findByYear() {
			var year = $("#datetimepicker").data("datetimepicker").getDate().getFullYear();
			console.log($("#datetimepicker").data("datetimepicker").getDate().getFullYear() + "###");
			//刚进页面加载数据
			ajaxLoadData({

				pageNo: 1,
				year: year
			});
		}

		function findProduct(id) {

			sessionStorage.setItem('companyId', id);
			location.href = "companyReportDetail.html";
			//href="companyReportDetail.html"
		}
	</script>

</head>

<body style="padding: 5px 10px">

	<div class="panel panel-primary">
		<div class="panel-heading">
			<h3 class="panel-title">企业报表</h3>
		</div>


		<div class="panel-body">

			<form class="form-inline" role="form" method="post" style="margin-bottom: 10px;" action="">
				<div class="form-group">
					<label for="time">查询年份</label>
					<input type="text" readonly="readonly" id="datetimepicker" data-date-format="yyyy"
						class="form-control" id="time" placeholder="">
				</div>
				<input type="button" class="btn btn-default" onclick="findByYear()" value="查询" />
				<input type="button" class="btn btn-danger" value="清空条件" />
				<hr />
			</form>
			<table class="table table-hover">
				<thead>
					<tr>
						<th>企业名称</th>
						<th>融资产品总数</th>
						<th>总融资目标</th>
						<th>实际融资数</th>
						<th>佣金</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody id="companyContent">
					<script id="companyTemplate" type="text/html">
	  			{{each sources as i}}
		  			<tr> 	 	 	 	 	 
		  				<td>{{i.companyName}}</td>
		  				<td>{{i.totalCount}}</td>
		  				<td>{{i.totalAmount}}万</td>
		  				<td>{{i.actAmount}}万</td>
		  				<td>{{i.rate}}万</td>
		  				<td>
		  					<a class="btn btn-primary btn-xs btn-success"  onclick="findProduct('{{i.companyId}}')"   >
		  						详情
		  						<span class="glyphicon glyphicon-list-alt"></span>
		  					</a>
		  				</td>
		  			</tr>
                 {{/each}}
</script>
				</tbody>
			</table>
		</div>
	</div>
	<div style="text-align: center;">
		<ul id="myPages"></ul>
	</div>
	<script type="text/javascript">
		$('#datetimepicker').datetimepicker({
			language: 'zh-CN',
			weekStart: 1,
			todayBtn: 1,
			autoclose: 1,
			todayHighlight: 1,
			startView: 4,
			minView: 4,
			forceParse: 0
		});
	</script>
</body>

</html>